local sock = require('sock')
if not sock then
	print('require sock fail')
end

print(sock.version())

local serv, err = sock.new('@tcp:127.0.0.1:8000')
if err then
	print(err)
	os.exit(-1)
end

print('fd:', serv:fd())
print('is_closed:', serv:is_closed())

local client, err = sock.new('>tcp:127.0.0.1:8000')
if err then
	print(err)
	os.exit(-1)
end
print('fd:', client:fd())
print('is_closed:', client:is_closed())

local cli, err = serv:accept()
if err then
	print('accept err:', err)
	os.exit(-1)
end


client:close()
cli:close()
serv:close()

print('done')

